package javase.jmx.timer;

import javax.management.Notification;
import javax.management.NotificationListener;

public class TimerNotificationListener implements NotificationListener {
	private int count;
	private String name;
	
	 public TimerNotificationListener(String name) {
		 this.name = name;
	 }
	
	@Override
	public void handleNotification(Notification notification, Object arg1) {
		count++;
		echo("\tType: " + notification.getType() + 
			 "\tSequence number: " + notification.getSequenceNumber());
	}

	private void echo(String message) {
		System.out.println(name + " : " + message);
	}
	
	public int getCount() {
		return count;
	}
	
	public String getName() {
		return name;
	}
}
